<template>
  <div class="App">
    <h2 ref='msg'>我是App组件</h2>
    <h2>{{msg}}</h2>
    <School ref="school" />
    <button @click="showMsg">点击</button>
  </div>
</template>

<script>
  import School from "./components/School";

  export default {
    name: "App",
    components: {
      School
    },
    data() {
      return {
        msg: '我是大司马'
      }
    },
    methods: {
      showMsg() {
        alert(this.$refs.msg.innerText);
        console.log(this.$refs.school);
      }
    }
  };
</script>

<style scope>
  .App {
    background-color: coral;
    padding: 30px;
  }
</style>